define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
         var typeU;
        if (Fast.api.query("type")==false || Fast.api.query("type")==null) {
           typeU=1;
        }else{
            typeU=Fast.api.query("type");
        }
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'store/haltcate/index/?type='+typeU,
                    del_url: 'store/haltcate/del/?type='+typeU,
                    edit_url: 'store/haltcate/edit/?type='+typeU,

                    // import_url: 'store/haltcate/import',
                    add_url: 'store/haltcate/add/?type='+typeU,

                    multi_url: 'store/haltcate/multi',
                    table: 'halt_cate',
                }
            });

            var table = $("#table");

            //  初始化表格
            var tableOptions =  table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                escape: false,
                pagination: false,
                commonSearch: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'name', title: __('Name'),align: 'left'},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {
                            field: 'operate',
                            width: "200px",
                            title: '操作',
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('添加'),
                                    text: __('添加'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-plus',
                                    url: 'store/haltcate/add?type='+typeU,
                                    callback: function (data) {
                                        Layer.alert("接收到回传数据：" + JSON.stringify(data), {title: "回传数据"});
                                    }
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        },
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });
            Table.api.bindevent(table);



        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter:{
                browser: function (value, row, index) {
                    //这里我们直接使用row的数据
                    return '<a class="btn btn-xs btn-browser" href="http://www.baidu.com">1111</a>';
                },
                views:function (value,row,index) {
                    var title="编辑";
                    var table = this.table;
                    // 默认按钮组
                    var buttons = [];
                    buttons.push({
                        name: 'detail',
                        title: title,
                        icon:'fa fa-pencil',
                        classname: 'btn btn-xs  btn-dialog',
                        url: 'store/haltcate/edit/ids?type='+row.type,
                    });
                    buttons.push({
                        name: '删除',
                        title: "删除",
                        icon:'fa fa-trash',
                        classname: 'btn btn-xs  btn-dialog',
                        url: 'store/haltcate/edit/ids?type='+row.type,
                    });
                    return Table.api.buttonlink(this, buttons, value, row, index, 'buttons');


                }

            }

        }
    };
    return Controller;
});